// 优先级队列  线性结构  多一个优先级的属性   例子：登机顺序 >>>  头等舱 商务舱

class QueueElement {
    constructor(element, order) {
        this.element = element;
        this.order = order;
    }
}

class Lx_prequeue {
    constructor() {
        this.items = [];
    }

    enqueue(element, order) {
        let queueElement = new QueueElement(element, order);
        if (this.items.length === 0) {
            this.items.push(queueElement);
        } else {
            var isAdd = false;
            for (var i = 0; i < this.items.length; i++) {
                if (queueElement.order < this.items[i].order) {
                    this.items.splice(i, 0, queueElement);
                    isAdd = true;
                    break;
                }
            }
            if (!isAdd) {
                this.items.push(queueElement);
            }
        }
    }
}

let prequeue = new Lx_prequeue();
